{include file="public/header-static"/}
{include file="public/sidebar"/}
<link rel="stylesheet" type="text/css" href="__STATIC__/webuploader-0.1.5/webuploader.css">

<div id="main">
    {include file="public/header"/}
    <main class="main-content">
        <div class="container">
            <div class="page-header">
                <nav aria-label="breadcrumb">
                    <ol class="breadcrumb">
                        <!--                        <li class="breadcrumb-item active" style="color: #4370FFFF;font-size: 18px; cursor: pointer;"-->
                        <!--                            onclick="goBack()" aria-current="page">< 返回-->
                        <!--                        </li>-->
                    </ol>
                </nav>
            </div>
            <div class="row">
                <div class="col-md-12">

                    <div class="card">
                        <!--                    <div class="card" style="padding-bottom: 150px;">-->
                        <div style="display: flex;justify-content: space-between;padding: 19px 25px;">
                            <i style="font-size: 22px; color: #457BFFFF;font-weight: 600;">待举办的活动</i>
                            <!--                            <span-->
                            <!--                                style="padding:5px 25px;color: #4270FFFF;border: 1px solid #4270FFFF;border-radius: 4px;">完成</span>-->
                        </div>
                        <div class="card-body">
                            <form action="{:url('/marketing/marketingEdit')}" method="post" target="iframe_form"
                                  enctype="multipart/form-data">

                                <div class="form-group row blueLabel">
                                    <input type="hidden" name="id" class="form-control" value="{$info.id}">
                                    <label for="" class="col-sm-2 col-form-label ">活动主题</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="title" class="form-control" placeholder="请输入活动主题" value="{$info.title}">
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">活动类型</label>
                                    <div class="col-sm-4">
                                        <select name="type" id="type" class="form-control">
                                            <option value="">请选择活动类型</option>
                                            <option value="1" {if $info.type == 1}selected{/if}>线上</option>
                                            <option value="2" {if $info.type == 2}selected{/if}>线下</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">活动地区</label>
                                    <div class="col-sm-8" style="display: flex;">
                                        <select name="province" id="province" class="form-control"
                                                style="width:33%;margin-right: 15px;">
                                            <option value="">请选择省份</option>
                                            {volist name="province" id="vo"}
                                            <option value="{$vo.location_id}" {if $info.province == $vo.location_id}selected{/if}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select name="city" id="city" class="form-control"
                                                style="width:33%;margin-right: 15px;">
                                            <option value="">请选择城市</option>
                                            {volist name="city" id="vo"}
                                            <option value="{$vo.location_id}" {if $info.city == $vo.location_id}selected{/if}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                        <select name="area" id="area" class="form-control" style="width:33%;">
                                            <option value="">请选择地区</option>
                                            {volist name="area" id="vo"}
                                            <option value="{$vo.location_id}" {if $info.area == $vo.location_id}selected{/if}>{$vo.name}</option>
                                            {/volist}
                                        </select>

                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">详细地址</label>
                                    <div class="col-sm-8" style="display: flex;">
                                        <input type="text" name="address" class="form-control" placeholder="详细地址" value="{$info.address}">
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">开始/结束时间</label>
                                    <div class="col-sm-8" style="display: flex;align-items: center;">
                                        <input name="start_time" type="text" autocomplete="off" id="startDate"
                                               class="layui-input"
                                               placeholder="开始日期" value="{$info.start_time}">
                                        <span style="margin:0 10px">-</span>
                                        <input name="end_time" type="text" autocomplete="off" id="endDate"
                                               class="layui-input"
                                               placeholder="结束日期" value="{$info.end_time}">
                                    </div>
                                </div>

                                <div class="form-group row blueLabel blueLabel2">
                                    <label class="col-sm-2 col-form-label">预算</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="budget" class="form-control" placeholder="预算" value="{$info.budget}">
                                    </div>
                                </div>

                                {in name="$userRole" value="1,6"}
                                    <div class="form-group row blueLabel blueLabel2">
                                        <label class="col-sm-2 col-form-label">经办人</label>
                                        <div class="col-sm-4">
                                            <select name="manager" id="manager" class="form-control">
                                                <option value="">请选择经办人</option>
                                                {volist name="officialStaff" id="vo"}
                                                <option value="{$vo.id}" {if $info.manager == $vo.id}selected{/if}>{$vo.alias}</option>
                                                {/volist}
                                            </select>
                                        </div>
                                    </div>
                                {else /}
                                    <input type="hidden" name="manager" placeholder="经办人" value="{$officialStaff}">
                                {/in}

                                <div class="form-group row blueLabel">
                                    <label class="col-sm-2 col-form-label">描述</label>
                                    <div class="col-sm-8">
                                        <textarea class="custom_text form-control" placeholder="描述"
                                                  name="desc">{$info.desc}</textarea>
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label class="col-sm-2 col-form-label">上传文件</label>

                                    <div class="col-sm-8">
                                        <!--                                    <div class="col-sm-8" style="flex: auto;max-width: 100%;">-->
                                        <input type="hidden" class="form-control files" name="files" required=""
                                               aria-required="true" value="{$info.filesPath}">

                                        <div id="uploadfile">
                                            <div class="form-group form-inline">
                                                <div id="pick_2655" style="float:left;font-weight: normal;">上传文件</div>
                                            </div>
                                        </div>

                                        <div class="layui-upload-list">
                                            <table class="layui-table" style="table-layout:fixed;">
                                                <thead>
                                                <tr>
                                                    <th width="60%">文件名</th>
                                                    <!--                                                    <th>大小</th>-->
                                                    <!--                                                    <th>状态</th>-->
                                                    <th>进度条</th>
                                                    <th width="10%">操作</th>
                                                </tr>
                                                </thead>
                                                <tbody id="the_2655">
                                                {php}
                                                    if ($info['marketingPath']) {

                                                    foreach ($info['marketingPath'] as $v) {

                                                {/php}
                                                    <tr>
                                                        <td width="20%">{$v['basename']}</td>
                                                        <td class="rate" width="40%">
                                                            <div class="layui-form-item1">
                                                                <div class="layui-progress layui-progress-big"
                                                                     lay-filter="rate" lay-showPercent="true">
                                                                    <div id="rate" class="layui-progress-bar"
                                                                         lay-percent="100.00%"
                                                                         style="width: 100%;text-align: left;">
                                                                        <span class="layui-progress-text"></span>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </td>
                                                        <td width="40%">
                                                            <button src="{$v['path']}"
                                                                    class="layui-btn layui-btn-xs layui-btn-danger demo-delete original"
                                                                    type="button" onclick="demo_delete(this)">删除
                                                            </button>
                                                        </td>
                                                    </tr>
                                                {php}
                                                    } }
                                                {/php}
                                                </tbody>
                                            </table>
                                        </div>

                                    </div>
                                </div>

                                <button type="submit" class="btn btn-secondary">发布</button>
                            </form>
                        </div>
                    </div>
                </div>


                <div class="col-md-6" style="display: none">
                    <div class="card">
                        <div style="display: flex;justify-content: space-between;padding: 19px 25px;">
                            <i style="font-size: 22px; color: #457BFFFF;font-weight: 600;">待举办的活动</i><span
                                style="padding:5px 25px;color: #4270FFFF;border: 1px solid #4270FFFF;border-radius: 4px;">编辑</span>
                        </div>
                        <div class="card-body card-body2" style="overflow: hidden;">
                            <form action="{:url('')}" method="post" target="iframe_form"
                                  enctype="multipart/form-data">

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">活动主题</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="name" class="form-control" placeholder="请输入活动主题">
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">活动类型</label>
                                    <div class="col-sm-8">
                                        <select name="province" id="province" class="form-control" style="width:33%;">
                                            <option value="">线下</option>
                                            <option value="">线上</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">活动地区</label>
                                    <div class="col-sm-8" style="display: flex;">
                                        <select name="province" id="province" class="form-control"
                                                style="width:20%;margin-right: 15px;">
                                            <option value="">请选择省份</option>
                                            <option value=""></option>
                                        </select>

                                        <select name="city" id="city" class="form-control"
                                                style="width:20%;margin-right: 15px;">
                                            <option value="">请选择城市</option>
                                        </select>

                                        <input type="text" id="area" class="form-control" style="flex: 1;"
                                               placeholder="">

                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">开始/结束时间</label>
                                    <div class="col-sm-8" style="display: flex;align-items: center;">
                                        <input type="text" autocomplete="off" id="startDate" class="layui-input"
                                               placeholder="开始日期">
                                        <span style="margin:0 10px">-</span>
                                        <input type="text" autocomplete="off" id="endDate" class="layui-input"
                                               placeholder="结束日期">
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label class="col-sm-2 col-form-label">预算</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                    <label class="col-sm-2 col-form-label">经办人</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label class="col-sm-2 col-form-label">描述</label>
                                    <div class="col-sm-8">
                                        <textarea class="custom_text form-control" placeholder="描述"
                                                  name="desc"></textarea>
                                    </div>
                                </div>

                                <div class="form-group row orangeLabel">
                                    <label class="col-sm-2 col-form-label">新用户人数</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                    <label class="col-sm-2 col-form-label">成功转换人数</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                </div>

                                <div class="form-group row orangeLabel">
                                    <label class="col-sm-2 col-form-label">消费金额</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                    <label class="col-sm-2 col-form-label">佣金</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                </div>

                                <div class="form-group row ">
                                    <!-- <label class="col-sm-2 col-form-label">二维码</label> -->
                                    <div class="col-sm-4">
                                        <input type="hidden" class="form-control qrcode" name="qrcode" required=""
                                               aria-required="true">
                                        <div style="background-color: #B00303FF;color: #fff;width: 100px;height: 100px;display: grid;place-items: center;margin-top: 31px;">
                                            码
                                        </div>
                                        <!-- <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            预览图：
                                            <div class="layui-upload-list uploader-list" style="overflow: auto;"
                                                 id="uploader-files">
                                            </div>
                                        </blockquote> -->
                                    </div>
                                </div>

                            </form>
                        </div>
                        <div class="bottom">
                            <div class="positionBox1" onclick="pullDown1('展开')"
                                 style="color: #5C5F66FF;cursor: pointer; display: none;">
                                展开
                                <div class="pullDown1"></div>
                            </div>
                            <div class="positionBox2" onclick="pullDown1('收起')"
                                 style="color: #5C5F66FF;cursor: pointer;">
                                收起
                                <div class="pullDown2"></div>
                            </div>
                        </div>
                    </div>

                    <div class="card">
                        <div style="display: flex;justify-content: space-between;padding: 19px 25px;">
                            <i style="font-size: 22px; color: #457BFFFF;font-weight: 600;">待举办的活动2</i><span
                                style="padding:5px 25px;color: #4270FFFF;border: 1px solid #4270FFFF;border-radius: 4px;">编辑</span>
                        </div>
                        <div class="card-body card-body3" style="overflow: hidden; height: 230px;">
                            <form action="{:url('')}" method="post" target="iframe_form"
                                  enctype="multipart/form-data">

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">活动主题</label>
                                    <div class="col-sm-8">
                                        <input type="text" name="name" class="form-control" placeholder="请输入活动主题">
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">活动类型</label>
                                    <div class="col-sm-8">
                                        <select name="province" id="province" class="form-control" style="width:33%;">
                                            <option value="">线下</option>
                                            <option value="">线上</option>
                                        </select>
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">活动地区</label>
                                    <div class="col-sm-8" style="display: flex;">
                                        <select name="province" id="province" class="form-control"
                                                style="width:20%;margin-right: 15px;">
                                            <option value="">请选择省份</option>
                                            <option value=""></option>
                                        </select>

                                        <select name="city" id="city" class="form-control"
                                                style="width:20%;margin-right: 15px;">
                                            <option value="">请选择城市</option>
                                        </select>

                                        <input type="text" id="area" class="form-control" style="flex: 1;"
                                               placeholder="">

                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label for="" class="col-sm-2 col-form-label">开始/结束时间</label>
                                    <div class="col-sm-8" style="display: flex;align-items: center;">
                                        <input type="text" autocomplete="off" id="startDate" class="layui-input"
                                               placeholder="开始日期">
                                        <span style="margin:0 10px">-</span>
                                        <input type="text" autocomplete="off" id="endDate" class="layui-input"
                                               placeholder="结束日期">
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label class="col-sm-2 col-form-label">预算</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                    <label class="col-sm-2 col-form-label">经办人</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                </div>

                                <div class="form-group row blueLabel">
                                    <label class="col-sm-2 col-form-label">描述</label>
                                    <div class="col-sm-8">
                                        <textarea class="custom_text form-control" placeholder="描述"
                                                  name="desc"></textarea>
                                    </div>
                                </div>

                                <div class="form-group row orangeLabel">
                                    <label class="col-sm-2 col-form-label">新用户人数</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                    <label class="col-sm-2 col-form-label">成功转换人数</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                </div>

                                <div class="form-group row orangeLabel">
                                    <label class="col-sm-2 col-form-label">消费金额</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                    <label class="col-sm-2 col-form-label">佣金</label>
                                    <div class="col-sm-4">
                                        <input type="text" name="uid" class="form-control" placeholder="">
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <!-- <label class="col-sm-2 col-form-label">二维码</label> -->
                                    <div class="col-sm-4">
                                        <input type="hidden" class="form-control qrcode" name="qrcode" required=""
                                               aria-required="true">
                                        <div style="background-color: #B00303FF;color: #fff;width: 100px;height: 100px;display: grid;place-items: center;margin-top: 31px;">
                                            码
                                        </div>
                                        <!-- <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            预览图：
                                            <div class="layui-upload-list uploader-list" style="overflow: auto;"
                                                 id="uploader-files">
                                            </div>
                                        </blockquote> -->
                                    </div>
                                </div>

                            </form>
                        </div>
                        <div class="bottom">
                            <div class="positionBox1 positionBox3" onclick="pullDown3('展开')"
                                 style="color: #5C5F66FF;cursor: pointer; ">
                                展开
                                <div class="pullDown1"></div>
                            </div>
                            <div class="positionBox2 positionBox4" onclick="pullDown3('收起')"
                                 style="color: #5C5F66FF;cursor: pointer;display: none;">
                                收起
                                <div class="pullDown2"></div>
                            </div>
                        </div>
                    </div>

                </div>

            </div>

        </div>
    </main>

    {include file="public/footer"/}
    <script type="text/javascript" src="__STATIC__/webuploader-0.1.5/webuploader.min.js"></script>
    <script>
        //注意进度条依赖 element 模块，否则无法进行正常渲染和功能性操作
        layui.use('element', function () {
            var element = layui.element,
                $ = layui.jquery;
            // element.progress('rate', '50%');
        });
    </script>
    <script>
        uploadFiles(2655, 'files');
        //上传文件函数
        //ids唯一ID
        //folder文件保存目录
        function uploadFiles(ids, folder) {
            $(function () {
                var $list = $("#the_" + ids);
                $btn = $("#Btn_" + ids);
                var uploader = WebUploader.create({
                    resize: false, // 不压缩image
                    swf: '__STATIC__/webuploader-0.1.5/Uploader.swf', // swf文件路径
                    server: '{:url("/upload/maxFieldsUpload")}', // 文件接收服务端。
                    pick: "#pick_" + ids, // 选择文件的按钮。可选
                    chunked: true, //是否要分片处理大文件上传
                    // 所有限制单位为字节
                    chunkSize: 5 * 1024 * 1024, //分片上传，每片5M，默认是5M
                    //fileSizeLimit: 6*1024* 1024 * 1024,    // 所有文件总大小限制 6G
                    fileSingleSizeLimit: 200 * 1024 * 1024,    // 单个文件大小限制 200MB
                    formData: {
                        folder: folder  //自定义参数
                    },
                    auto: true //选择文件后是否自动上传
                    // chunkRetry : 2, //如果某个分片由于网络问题出错，允许自动重传次数
                    //runtimeOrder: 'html5,flash',
                    // accept: {
                    //   title: 'Images',
                    //   extensions: 'gif,jpg,jpeg,bmp,png',
                    //   mimeTypes: 'image/*'
                    // }
                });
                // 当有文件被添加进队列的时候
                uploader.on('fileQueued', function (file) {
                    console.log(file)
                    $list.append('<tr id="' + file.id + '">\n' +
                        '<td width="20%">' + file.name + '</td>\n' +
                        // '<td class="state">等待上传...</td>\n' +
                        '<td class="rate" width="40%">' +
                        '<div class="layui-form-item1">\n' +
                        '<div class="layui-progress layui-progress-big" lay-filter="rate_' + file.id + '" lay-showPercent="true">\n' +
                        '<div id="rates_' + file.id + '" class="layui-progress-bar" lay-percent="0%" style="width: 0%;text-align: left;"><span class="layui-progress-text">0%</span></div>\n' +
                        '</div>\n' +
                        '</div>' +
                        '</td>\n' +
                        '<td width="40%">\n' +
                        '<button id="subPath_' + file.id + '" class="layui-btn layui-btn-xs layui-btn-danger demo-delete" type="button" onclick="demo_delete(this)">删除</button>\n' +
                        '</td>\n' +
                        '</tr>');
                });
                // 文件上传过程中创建进度条实时显示。
                uploader.on('uploadProgress', function (file, percentage) {
                    progress = (Math.min(100, (percentage) * 100)).toFixed(2) + '%';

                    console.log(percentage, (Math.min(100, (percentage) * 100)), progress)
                    if ((Math.min(100, (percentage) * 100)).toFixed(2) >= 100) {
                        console.log('我完成了啊')
                    }

                    layui.element.progress('rate_' + file.id, progress);
                });

                // 文件上传成功
                uploader.on('uploadSuccess', function (file, response) {
                    console.log(file, response, $('#rates_' + file.id));
                    var files = $('.files').val();
                    if (files != '') {
                        files += ',' + response.subFilePath;
                    } else {
                        files = response.subFilePath;
                    }
                    $('.files').val(files);
                    $('#subPath_' + file.id).attr("src", response.subFilePath);
                });

                // 文件上传失败，显示上传出错
                uploader.on('uploadError', function (file) {
                    $('#rates_' + file.id).css('background-color', 'red');
                });

                // 完成上传完
                uploader.on('uploadComplete', function (file) {
                    console.log('完成上传完');
                    $('#' + file.id).find('.progress').fadeOut();
                });

                $btn.on('click', function () {
                    if ($(this).hasClass('disabled')) {
                        return false;
                    }
                    uploader.upload();
                    // if (state === 'ready') {
                    //     uploader.upload();
                    // } else if (state === 'paused') {
                    //     uploader.upload();
                    // } else if (state === 'uploading') {
                    //     uploader.stop();
                    // }
                });
            });
        }

        // 上传-删除
        function demo_delete(thiss) {
            var src = $(thiss).attr('src');
            console.log(thiss, $(thiss), src)
            var filesArr = $('.files').val().split(',');
            console.log(filesArr);
            var index1 = $.inArray(src, filesArr);
            console.log(index1);
            if (index1 > -1) {
                filesArr.splice(index1, 1);
                $('.files').val(filesArr);
            }
            // 不是原数据，删除
            if(!$(thiss).is('.original')) {
                console.log('不是原数据，删除');
                delImageOrVideo(src);
            }
            $(thiss).parent().parent().remove();
        }
    </script>


    <script type="text/javascript">
        function demo_delete(thiss) {
            var src = $(thiss).attr('src');
            console.log(thiss, $(thiss), src)
            var filesArr = $('.files').val().split(',');
            console.log(filesArr);
            var index1 = $.inArray(src, filesArr);
            console.log(index1);
            if (index1 > -1) {
                filesArr.splice(index1, 1);
                $('.files').val(filesArr);
            }
            $(thiss).parent().parent().remove();
        }

        function pullDown1(params) {
            if (params == '展开') {
                $('.card-body2').css('height', '100%')
                $('.positionBox1').css('display', 'none')
                $('.positionBox2').css('display', 'block')
            } else if (params == '收起') {
                $('.card-body2').css('height', '230px')
                $('.positionBox1').css('display', 'block')
                $('.positionBox2').css('display', 'none')
            }
        }

        function pullDown3(params) {
            if (params == '展开') {
                $('.card-body3').css('height', '100%')
                $('.positionBox3').css('display', 'none')
                $('.positionBox4').css('display', 'block')
            } else if (params == '收起') {
                $('.card-body3').css('height', '230px')
                $('.positionBox3').css('display', 'block')
                $('.positionBox4').css('display', 'none')
            }
        }

        function goBack() {
            window.location.href = '{:url("/marketing/index")}';
        }

        function getNowFormatDate() {
            var date = new Date();
            var seperator1 = "-";
            var seperator2 = ":";
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
                + " " + date.getHours() + seperator2 + date.getMinutes()
                + seperator2 + date.getSeconds();
            return currentdate;
        }

        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            //时间选择器
            laydate.render({
                elem: '#startDate'
                , type: 'datetime'
                , min: getNowFormatDate()
            });
            laydate.render({
                elem: '#endDate'
                , type: 'datetime'
                , min: getNowFormatDate()
            });
        });

        $(function () {
            // 城市
            $('#province').change(function () {
                var pid = $("#province option:selected").val();
                $.ajax({
                    type: "post",
                    url: '{:url("/location/getCity")}',
                    data: {'pid': pid},
                    success: function (res) {
                        console.log(res, res.code)
                        if (res.code == 1) {
                            result = res.data;
                            var strocity = '<option value="">请选择城市</option>';
                            for (var i = 0; i < result.length; i++) {
                                strocity += '<option value=' + result[i].location_id + '>';
                                strocity += result[i].name;
                                strocity += '</option>';
                            }
                            $("#city").text('');
                            $("#area").text('');
                            $("#area").append('<option value="">请选择地区</option>');
                            $("#city").append(strocity);
                        } else {
                            toastr.error(res.msg);
                        }
                    }
                })
            });

            // 地区
            $('#city').change(function () {
                var pid = $("#city option:selected").val();
                $.ajax({
                    type: "post",
                    url: '{:url("/location/getArea")}',
                    data: {'pid': pid},
                    success: function (res) {
                        if (res.code == 1) {
                            result = res.data;
                            var strocity = '<option value="">请选择地区</option>';
                            for (var i = 0; i < result.length; i++) {
                                strocity += '<option value=' + result[i].location_id + '>';
                                strocity += result[i].name;
                                strocity += '</option>';
                            }
                            $("#area").text('');
                            $("#area").append(strocity);
                        } else {
                            toastr.error(res.msg);
                        }
                    }
                })
            });
        });


        // 初始化资源图路径
        var imagesArr = [];
        // 各种上传
        layui.use('upload', function () {
            var $ = layui.jquery
                , upload = layui.upload;

            // 文件上传
            upload.render({
                elem: '#files'
                , accept: 'file'
                , url: '{:url("/upload/maxFieldsUpload")}?path=marketingFiles'
                , before: function (obj) {
                    layer.msg('文件上传中...', {
                        icon: 16,
                        shade: 0.05,
                        time: 0
                    });
                }
                // ,bindAction: '#testListAction'
                , choose: function (obj) {
                    var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                    //读取本地文件
                    obj.preview(function (index, file, result) {
                        var tr = $(['<tr id="upload-' + index + '">'
                            , '<td>' + file.name + '</td>'
                            // ,'<td>'+ (file.size/1024).toFixed(1) +'kb</td>'
                            , '<td>等待上传</td>'
                            , '<td>'
                            , '<button class="layui-btn layui-btn-xs layui-btn-danger demo-delete">删除</button>'
                            , '</td>'
                            , '</tr>'].join(''));

                        //删除
                        tr.find('.demo-delete').on('click', function () {
                            //删除对应的文件
                            delete files[index];
                            tr.remove();
                            uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                            delImageOrVideo(tr.children().eq(0).attr('src'));
                            var filess = $('.files').val();
                            var filessArr = filess.split(',');
                            // console.log(filess,filessArr);
                            var index1 = $.inArray(tr.children().eq(0).attr('src'), filessArr);
                            console.log(index1);
                            if (index1 > -1) {
                                filessArr.splice(index1, 1);
                                $('.files').val(filessArr);
                            }
                        });

                        demoListView.append(tr);
                    });
                }
                //上传完毕
                , done: function (res, index, upload) {
                    layer.close(layer.msg());//关闭上传提示窗口
                    if (res.code != 1) {
                        return toastr.error(res.msg);
                    }
                    console.log(res, res.data);
                    var files = $('.files').val();
                    if (files != '') {
                        files += ',' + res.data;
                    } else {
                        files = res.data;
                    }
                    $('.files').val(files);
                    var tr = demoListView.find('tr#upload-' + index), tds = tr.children();
                    // console.log(tds)
                    tds.eq(0).attr('src', res.data);
                    tds.eq(1).html('<span style="color: #5FB878;">上传成功</span>');
                    return delete this.files[index]; //删除文件队列已经上传成功的文件
                    // $('#uploader-files').append(
                    //     '<div id="" class="file-iteme">' +
                    //     '<div class="handle" src="'+ res.data +'"><span class="fa fa-times" style="border-radius: 0.375rem 0.375rem 0 0;"></span></div>' +
                    //     '<img style="width: 5rem;height: 5rem;border-radius: 0.375rem;" src='+ res.data +'>' +
                    //     // '<div class="info">' + res.data.name + '</div>' +
                    //     '</div>'
                    // );
                }
                // , done: function (res) {
                //     layer.close(layer.msg());//关闭上传提示窗口
                //     // console.log(res)
                //     //上传完毕
                //     var files = $('.files').val();
                //     if (files != '') {
                //         // 删除旧图片
                //         delImageOrVideo(files);
                //         $('#uploader-files').children('.file-iteme').remove();
                //     }
                //     $('.qrcode').val(res.data.src);
                //     $('#uploader-files').append(
                //         '<div id="" class="file-iteme">' +
                //         '<div class="handle" src="' + res.data.src + '"><span class="fa fa-times" style="border-radius: 0.375rem 0.375rem 0 0;"></span></div>' +
                //         '<img title=\'点我查看原文件\' style="width: 5rem;height: 5rem;border-radius: 0.375rem;cursor: pointer" src=' + res.data.src + ' onclick="lookimg(this.src)">' +
                //         // '<div class="info">' + res.data.name + '</div>' +
                //         '</div>'
                //     );
                // }
            });

        });

        // 删除图片
        $(document).on("click", ".file-iteme .handle", function (event) {
            console.log($(this).attr('src'))
            var parents = $(this).parents();
            var files = parents.eq(3).children('.files');
            console.log(files)
            if (files.val() != '') {
                files.val('');
            }
            delImageOrVideo($(this).attr('src'));
            $(this).parent().remove();
        });

    </script>


</div>

<style>
    .blueLabel {
        font-weight: 600;
        color: #000000FF;
        position: relative;
    }

    .blueLabel:before {
        content: '';
        position: absolute;
        top: 0;
        left: 1%;
        display: block;
        width: 26px;
        height: 26px;
        border-radius: 4px;
        background-color: #ECEFFFFF;
    }

    .orangeLabel {
        font-weight: 600;
        color: #000000FF;
        position: relative;
    }

    .orangeLabel:before {
        content: '';
        position: absolute;
        top: 0;
        left: 1%;
        display: block;
        width: 26px;
        height: 26px;
        border-radius: 4px;
        background-color: #FEE0D3FF;
    }

    .bottom {
        display: grid;
        place-items: center;
        margin-bottom: 20px;
    }

    .positionBox1, .positionBox2 {
        position: relative;
    }

    .positionBox2 .pullDown2 {
        position: absolute;
        left: 70%;
        bottom: -90%;
        transform: rotate(180deg);
        cursor: pointer;
    }

    .positionBox1 .pullDown1 {
        position: absolute;
        right: -70%;
        bottom: -10%;
        transform: rotate(180deg);
        cursor: pointer;
    }

    .pullDown1:before, .pullDown1:after, .pullDown2:before, .pullDown2:after {
        position: absolute;
        content: '';
        border-top: 7px transparent dashed;
        border-left: 7px transparent dashed;
        border-right: 7px transparent dashed;
        border-bottom: 7px #fff solid;
    }

    .pullDown1:before, .pullDown2:before {
        border-bottom: 7px #5C5F66FF solid;
    }

    .pullDown1:after, .pullDown2:after {
        top: 2px;
        border-bottom: 7px #fff solid;
    }
</style>